<script>
export default {
  name: 'PaymentSuccess',
  data() {
    return {
      isMobile: false,
      orderId: this.$route.query.orderId || ''
    }
  },
  methods: {
    checkDevice() {
      this.isMobile = window.innerWidth <= 750
    },
    viewOrder() {
      this.$router.push(`/order/detail/${this.orderId}`)
    },
    goHome() {
      this.$router.push('/')
    }
  },
  created() {
    this.checkDevice()
    window.addEventListener('resize', this.checkDevice)
  },
  beforeDestroy() {
    window.removeEventListener('resize', this.checkDevice)
  }
}
</script>

<template>
  <div class="content" :class="{ 'is-mobile': isMobile }">
    <heads :current="1"></heads>
    <div class="success-container">
      <div class="success-card">
        <div class="success-icon">
          <i class="el-icon-check"></i>
        </div>
        <h1>{{ $t('payment.paymentSuccess') }}</h1>
        <div class="order-info">
          <p class="order-number">{{ $t('payment.orderNumber') }}: {{ orderId }}</p>
          <p class="email-notice">{{ $t('payment.emailNotice') }}</p>
        </div>
        <div class="actions">
<!--          <el-button type="primary" @click="viewOrder">{{ $t('payment.viewOrder') }}</el-button>-->
          <el-button @click="goHome">{{ $t('payment.returnToHome') }}</el-button>
        </div>
      </div>
    </div>
    <foot></foot>
  </div>
</template>

<style scoped lang="less">
.success-container {
  min-height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background-color: #f5f7fa;
}

.success-card {
  background: #fff;
  border-radius: 8px;
  padding: 40px;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  max-width: 500px;
  width: 100%;

  .success-icon {
    width: 80px;
    height: 80px;
    background: #0F7CD0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;

    i {
      font-size: 40px;
      color: #fff;
    }
  }

  h1 {
    color: #333;
    font-size: 24px;
    margin-bottom: 20px;
  }

  .order-info {
    margin-bottom: 30px;

    .order-number {
      font-size: 16px;
      color: #666;
      margin-bottom: 10px;
    }

    .email-notice {
      color: #909399;
      font-size: 14px;
      line-height: 1.5;
    }
  }

  .actions {
    display: flex;
    gap: 15px;
    justify-content: center;

    .el-button {
      min-width: 120px;
    }
  }
}

.is-mobile {
  .success-card {
    padding: 30px 20px;

    .success-icon {
      width: 60px;
      height: 60px;

      i {
        font-size: 30px;
      }
    }

    h1 {
      font-size: 20px;
    }

    .actions {
      flex-direction: column;
      gap: 10px;

      .el-button {
        width: 100%;
      }
    }
  }
}
</style>
